Skip to content

fix(rivetkit): expose client actor metadata#5016

Draft
NathanFlurry wants to merge 1 commit into
counter-latency/unbounded-dispatch-channelsfrom
counter-latency/client-protocol-polish
Draft

fix(rivetkit): expose client actor metadata#5016
NathanFlurry wants to merge 1 commit into
counter-latency/unbounded-dispatch-channelsfrom
counter-latency/client-protocol-polish

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 11, 2026

Code Review: fix(rivetkit): expose client actor metadata

Overview

This PR does three things:

  1. Adds the actor metadata field to the AsyncAPI spec (catching the docs up to the existing implementation)
  2. Adds a CLAUDE.md note on client/server protocol versioning assumption
  3. Pre-populates #actorId in the ActorConnRaw constructor for getForId resolution states so the ID is available before the WebSocket Init message arrives

Small, focused change with good intent. A few items worth addressing before marking ready.


Issues

1. Test does not exercise the constructor fix (medium)

The new test uses client.counter.getOrCreate(...), which produces a getOrCreateForKey resolution state, not a getForId state. The constructor fix (if ("getForId" in actorResolutionState)) is therefore never exercised. actorId in that test comes from the WebSocket Init message (line 728), which already worked before this PR.

To cover the new path, add a case that:

  1. Resolves an actor ID first via handle.resolve()
  2. Opens a getForId connection via client.getForId(actorId)
  3. Checks connection.actorId before await connection.ready - that is the behavior the constructor change unlocks

2. actorId JSDoc still says "for testing purposes" / @internal (low)

actor-conn.ts:1463-1469: The getter is marked @internal with "for testing purposes". If this is being promoted to a stable public API for users to read the resolved actor ID, the JSDoc needs updating. If it stays @internal, callers outside tests should not rely on it.

3. asyncapi.json generation field type is redundant (low)

Both schema additions declare anyOf: number or integer/int64. A JSON Schema integer is a strict subset of number, so the anyOf always reduces to number. The intent seems to be expressing the TypeScript z.union(z.number(), z.bigint()) distinction, but that is a JS runtime type difference, not a JSON Schema distinction. Using just integer/int64 alone would be cleaner and avoid confusing generator tooling.

4. CLAUDE.md note placement is slightly off (low)

The new bullet is placed in the BARE/vbare schema section, but the statement ("client sends its latest request protocol version; servers handle older-client compatibility") is a general protocol versioning principle, not BARE-specific. Consider moving it to a higher-level section.


What looks good

  • The core fix is correct: for a getForId resolution state the actor ID is known at construction time, so populating #actorId early is the right call.
  • Existing reconnect/clear logic (#clearResolvedActorIdentity + Init message re-set) remains intact and consistent with the early initialization.
  • The actor schema additions in asyncapi.json match ActorSpecifierSchema in client-protocol-zod.ts exactly (actorId required, generation required, key optional).
  • The HttpResponseErrorSchema parity (second asyncapi.json hunk) is also correct.

@MasterPtato MasterPtato force-pushed the counter-latency/unbounded-dispatch-channels branch from a499917 to da0205b Compare May 19, 2026 19:03
@MasterPtato MasterPtato force-pushed the counter-latency/client-protocol-polish branch from 6127de0 to 9115227 Compare May 19, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant